package xyz.riceball.generator.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import xyz.riceball.generator.entity.po.FieldMappingPO;
import xyz.riceball.generator.mapper.FieldMappingMapper;
import xyz.riceball.generator.service.FieldMappingService;

/**
 * 数据库类型字段映射表(FieldMapping)表服务实现类
 *
 * @author xiaovcloud
 * @since 2022-05-13 23:09:11
 */
@Service("fieldMappingService")
public class FieldMappingServiceImpl extends ServiceImpl<FieldMappingMapper, FieldMappingPO> implements FieldMappingService {

    @Override
    public Page<FieldMappingPO> selectPage(Page<FieldMappingPO> page, FieldMappingPO fieldMappingPO) {
        LambdaQueryWrapper<FieldMappingPO> wrapper = Wrappers.<FieldMappingPO>lambdaQuery();
        if (StrUtil.isNotEmpty(fieldMappingPO.getSourceValue())) {
            wrapper.eq(FieldMappingPO::getSourceValue, fieldMappingPO.getSourceValue());
        }
        if (StrUtil.isNotEmpty(fieldMappingPO.getTargetValue())) {
            wrapper.eq(FieldMappingPO::getTargetValue, fieldMappingPO.getTargetValue());
        }
        if (StrUtil.isNotEmpty(fieldMappingPO.getBdtype())) {
            wrapper.eq(FieldMappingPO::getBdtype, fieldMappingPO.getBdtype());
        }
        if (StrUtil.isNotEmpty(fieldMappingPO.getBdtype())) {
            wrapper.eq(FieldMappingPO::getBdtype, fieldMappingPO.getBdtype());
        }
        if (StrUtil.isNotEmpty(fieldMappingPO.getValid())) {
            wrapper.eq(FieldMappingPO::getValid, fieldMappingPO.getValid());
        }
        return getBaseMapper().selectPage(page, wrapper);
    }
}

